package org.example;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ShoppingCart {
    List<Product> shoppingCart = new ArrayList<>();
    Scanner scanner = new Scanner(System.in);


    {
        System.out.println("请输入商品名称（购物结束请输入'end'）：");
        String productName = scanner.nextLine();

        int count = 0;
        count++;
        System.out.println("当前商品数量" + count);
        if (count == 10) {
            System.out.println("购物车已满，请尽快清空！");
            break;
        }//购物车上限

        else if ("end".equals(productName)) {
            break;
        }//进购物车

        System.out.println("请输入商品的价格：");
        double price = scanner.nextDouble();
        scanner.nextLine();

        System.out.println("请输入商品类别：");
        String type = scanner.nextLine();
        scanner.nextLine();

        System.out.println("请输入商品的数量：");
        int number = scanner.nextInt();
        scanner.nextLine();

        Product product = new Product(productName, price, type, number);
        shoppingCart.add(product);
    }
}